// 完成与权限表相关的操作
const db = require('./db.js')

// 完成对所有权限的查询
module.exports.getAllPerm = ()=>{
	return db.q('SELECT * FROM sp_permission_api as api LEFT JOIN sp_permission as main ON main.ps_id = api.ps_id WHERE main.ps_id is not null',null)
	
}

module.exports.getPermCount = async ()=>{
	return await db.q('select count(*) cou from sp_permission',null)
}

module.exports.getPermByPage = async (pageInfo) =>{
	let sql = 'SELECT * FROM sp_permission p INNER JOIN sp_permission_api pa ON p.ps_id=pa.ps_id LIMIT ?,?';
	return await db.q(sql,pageInfo);	
}

